package com.woniuxy.store.core.controller;


import com.woniuxy.common.CommonResult;
import com.woniuxy.store.core.model.MdStoresecond;
import com.woniuxy.store.core.service.MdStoresecondService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gmx
 * @since 2021-06-29
 */
@RestController
@RequestMapping("mdStoresecond")
public class MdStoresecondController {
    @Autowired
    MdStoresecondService mdStoresecondService;

    //查新所有菜单列表
    @GetMapping("/selectAll")
    public CommonResult selectAll(){
        List<MdStoresecond> storesecondList=this.mdStoresecondService.list();
        return CommonResult.success(storesecondList);
    }

    //查询一个二级菜单信息
    @GetMapping("/selectOne/{secondId}")
    public CommonResult selectOne(@PathVariable("secondId") int secondId) {
        MdStoresecond  mdStoresecond=this.mdStoresecondService.getById(secondId);
        return CommonResult.success(mdStoresecond);
    }

    //修改一个二级菜单信息信息
    @PostMapping("updateOne")
    public CommonResult updateOne(@RequestBody MdStoresecond mdStoresecond){
        boolean b=  this.mdStoresecondService.updateById(mdStoresecond);
        if(b){
            return CommonResult.success("更新成功");}
        else {
            return CommonResult.fail();
        }
    }

    //增加一个二级菜单信息
    @PostMapping("/insertOne")
    public CommonResult insertOne(@RequestBody MdStoresecond mdStoresecond){
        this.mdStoresecondService.insertOne(mdStoresecond);
        return CommonResult.success("插入成功");
    }
    //删除一个二级菜单信息
    @GetMapping("delectOne/{secondId}")
    public CommonResult delectOnestore(@PathVariable("secondId") int secondId) {
        this.mdStoresecondService.delectOne(secondId);
        return CommonResult.success("注销成功");
    }

}

